﻿namespace WMS6.Web.Outbound
{
    using System;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;
    using WMS6.Web;
    using WMS6.Web.UserControls;

    public class ShippingOrderQuery : BasePage
    {
        protected Button btnExport;
        protected Button btnList;
        protected Button btnNew;
        protected Button btnSearch;
        protected DropDownList ddlActualShipDate;
        protected DropDownList ddlBillToID;
        protected DropDownList ddlConsigneeID;
        protected DropDownList ddlDeliveryDate;
        protected DropDownList ddlDriverName;
        protected DropDownList ddlExternOrderID;
        protected DropDownList ddlIsActive;
        protected DropDownList ddlIsActiveOper;
        protected DropDownList ddlOrderDate;
        protected DropDownList ddlOrderGroup;
        protected DropDownList ddlOrdersID;
        protected DropDownList ddlOwnerID;
        protected DropDownList ddlPriority;
        protected DropDownList ddlReferenceNum;
        protected DropDownList ddlRequestedShipDate;
        protected DropDownList ddlShipTogether;
        protected DropDownList ddlShipTogetherOpr;
        protected DropDownList ddlStatusOper;
        protected DropDownList ddlTransportMode;
        protected DropDownList ddlTypeOpr;
        protected DropDownList ddlWaveID;
        protected HtmlForm F7010;
        protected HtmlInputHidden hdnActionID;
        protected HtmlInputHidden hdncalendarFlag;
        protected HtmlInputHidden hdnDataFormat;
        protected HtmlInputHidden hdnDeclarationsType;
        protected HtmlImage img1;
        protected HtmlImage img2;
        protected HtmlImage img3;
        protected HtmlImage img4;
        protected Label lblActualShipDate;
        protected Label lblBillToID;
        protected Label lblConsigneeID;
        protected Label lblDeliveryDate;
        protected Label lblDriverName;
        protected Label lblExternOrderID;
        protected Label lblIsActive;
        protected Label lblOrderDate;
        protected Label lblOrderGroup;
        protected Label lblOrdersID;
        protected Label lblOwnerID;
        protected Label lblPriority;
        protected Label lblReceiptQuery;
        protected Label lblReferenceNum;
        protected Label lblRequestedShipDate;
        protected Label lblShipTogether;
        protected Label lblStatus;
        protected Label lblTransportMode;
        protected Label lblType;
        protected Label lblWaveID;
        protected MultipleSelectControl MSCStatus;
        protected MultipleSelectControl MSCTransportMode;
        protected MultipleSelectControl MSCType;
        protected HtmlLink mycss;
        protected HtmlImage OwnerIDImg;
        protected TextBox txtActualShipDate;
        protected TextBox txtActualShipDate2;
        protected TextBox txtBillToID;
        protected TextBox txtConsigneeID;
        protected TextBox txtDeliveryDate;
        protected TextBox txtDeliveryDate2;
        protected TextBox txtDriverName;
        protected TextBox txtExternOrderID;
        protected TextBox txtOrderDate;
        protected TextBox txtOrderDate2;
        protected TextBox txtOrderGroup;
        protected TextBox txtOrdersID;
        protected TextBox txtOwnerID;
        protected TextBox txtPriority;
        protected TextBox txtReferenceNum;
        protected TextBox txtRequestedShipDate;
        protected TextBox txtRequestedShipDate2;
        protected TextBox txtWaveID;

        protected void btnList_Click(object sender, EventArgs e)
        {
            base.Server.Transfer(string.Format("ShippingOrderList.aspx?action={0}&from=list&type={1}", base.UrlEncode(this.hdnActionID.Value.Trim()), base.Request.QueryString["OrderStatus"]), false);
        }

        protected void btnSearch_Click(object sender, EventArgs e)
        {
            base.Server.Transfer(string.Format("ShippingOrderList.aspx?action={0}&type={1}", base.UrlEncode(this.hdnActionID.Value.Trim()), base.Request.QueryString["OrderStatus"]), false);
        }

        private void LoadData()
        {
            if (!string.IsNullOrEmpty(base.Request.QueryString["action"]))
            {
                this.btnNew.Visible = false;
                this.btnExport.Visible = false;
            }
            if (!string.IsNullOrEmpty(base.Request.QueryString["OwnerID"]))
            {
                this.OwnerIDImg.Attributes.Add("onclick", "");
                this.txtOwnerID.Text = base.Request.QueryString["OwnerID"];
                this.txtOwnerID.Enabled = false;
            }
            if (!string.IsNullOrEmpty(base.Request.QueryString["DeclarationsType"]))
            {
                this.hdnDeclarationsType.Value = base.Request.QueryString["DeclarationsType"];
            }
        }

        private void LoadDDL()
        {
            base.BindData2DDLBySysCode(this.MSCType, "OrderType");
            base.BindData2DDLBySysCode(this.MSCStatus, "OrderStatus", base.Request.QueryString["OrderStatus"]);
            base.BindData2DDLBySysCode(this.MSCTransportMode, "TransportMode");
            base.InitQueryDDL(this.ddlOrdersID, 0);
            base.InitQueryDDL(this.ddlReferenceNum, 0);
            base.InitQueryDDL(this.ddlOwnerID, 0);
            base.InitQueryDDL(this.ddlOrderDate, 1);
            base.InitQueryDDL(this.ddlRequestedShipDate, 1);
            base.InitQueryDDL(this.ddlActualShipDate, 1);
            base.InitQueryDDL(this.ddlDeliveryDate, 1);
            base.InitQueryDDL(this.ddlPriority, 0);
            base.InitQueryDDL(this.ddlTypeOpr, 0);
            this.ddlTypeOpr.SelectedValue = "One Of";
            base.InitQueryDDL(this.ddlStatusOper, 0);
            this.ddlStatusOper.SelectedValue = "One Of";
            base.InitQueryDDL(this.ddlOrderGroup, 0);
            base.InitQueryDDL(this.ddlExternOrderID, 0);
            base.InitQueryDDL(this.ddlConsigneeID, 0);
            base.InitQueryDDL(this.ddlBillToID, 0);
            base.InitQueryDDL(this.ddlWaveID, 0);
            base.InitQueryDDL(this.ddlDriverName, 0);
            base.InitQueryDDL(this.ddlTransportMode, 0);
            this.ddlTransportMode.SelectedValue = "One Of";
            base.InitQueryDDL(this.ddlShipTogetherOpr, 0);
            base.InitQueryDDL(this.ddlIsActiveOper, 0);
            base.InitIsActiveDDL(this.ddlShipTogether, 0);
            base.InitIsActiveDDL(this.ddlIsActive, 0);
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!base.IsPostBack)
            {
                base.InitPage(this.Page);
                this.LoadData();
                this.LoadDDL();
            }
        }

        public string ActualShipDate
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtActualShipDate.Text.Trim()))
                {
                    return base.GetParamsString(this.txtActualShipDate.Text.Trim(), this.ddlActualShipDate.SelectedValue, this.txtActualShipDate2.Text.Trim(), "ActualShipDate");
                }
                return "";
            }
        }

        public string BillToID
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtBillToID.Text.Trim()))
                {
                    return base.GetParamsString(this.txtBillToID.Text.Trim(), this.ddlBillToID.SelectedValue);
                }
                return "";
            }
        }

        public string ConsigneeID
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtConsigneeID.Text.Trim()))
                {
                    return base.GetParamsString(this.txtConsigneeID.Text.Trim(), this.ddlConsigneeID.SelectedValue);
                }
                return "";
            }
        }

        public string DeclarationsType
        {
            get
            {
                if (!string.IsNullOrEmpty(this.hdnDeclarationsType.Value))
                {
                    return this.hdnDeclarationsType.Value;
                }
                return "";
            }
        }

        public string DeliveryDate
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtDeliveryDate.Text.Trim()))
                {
                    return base.GetParamsString(this.txtDeliveryDate.Text.Trim(), this.ddlDeliveryDate.SelectedValue, this.txtDeliveryDate2.Text.Trim(), "DeliveryDate");
                }
                return "";
            }
        }

        public string Door
        {
            get
            {
                return "";
            }
        }

        public string DriverName
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtDriverName.Text))
                {
                    return base.GetParamsString(this.txtDriverName.Text, this.ddlDriverName.SelectedValue);
                }
                return "";
            }
        }

        public string ExternOrderID
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtExternOrderID.Text.Trim()))
                {
                    return base.GetParamsString(this.txtExternOrderID.Text.Trim(), this.ddlExternOrderID.SelectedValue);
                }
                return "";
            }
        }

        public string IsActive
        {
            get
            {
                if (!string.IsNullOrEmpty(this.ddlIsActive.SelectedValue))
                {
                    return base.GetParamsString(this.ddlIsActive.SelectedValue, this.ddlIsActiveOper.SelectedValue);
                }
                return "";
            }
        }

        public string OrderDate
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtOrderDate.Text.Trim()))
                {
                    return base.GetParamsString(this.txtOrderDate.Text.Trim(), this.ddlOrderDate.SelectedValue, this.txtOrderDate2.Text.Trim(), "OrderDate");
                }
                return "";
            }
        }

        public string OrderGroup
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtOrderGroup.Text.Trim()))
                {
                    return base.GetParamsString(this.txtOrderGroup.Text.Trim(), this.ddlOrderGroup.SelectedValue);
                }
                return "";
            }
        }

        public string OrdersID
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtOrdersID.Text.Trim()))
                {
                    return base.GetParamsString(this.txtOrdersID.Text.Trim(), this.ddlOrdersID.SelectedValue);
                }
                return "";
            }
        }

        public string OwnerID
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtOwnerID.Text.Trim()))
                {
                    return base.GetParamsString(this.txtOwnerID.Text.Trim(), this.ddlOwnerID.SelectedValue);
                }
                return "";
            }
        }

        public string Priority
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtPriority.Text.Trim()))
                {
                    return base.GetParamsString(this.txtPriority.Text.Trim(), this.ddlPriority.SelectedValue);
                }
                return "";
            }
        }

        public string ReferenceNum
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtReferenceNum.Text))
                {
                    return base.GetParamsString(this.txtReferenceNum.Text, this.ddlReferenceNum.SelectedValue);
                }
                return "";
            }
        }

        public string RequestedShipDate
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtRequestedShipDate.Text.Trim()))
                {
                    return base.GetParamsString(this.txtRequestedShipDate.Text.Trim(), this.ddlRequestedShipDate.SelectedValue, this.txtRequestedShipDate2.Text.Trim(), "RequestedShipDate");
                }
                return "";
            }
        }

        public string Route
        {
            get
            {
                return "";
            }
        }

        public string ShipTogether
        {
            get
            {
                if (!string.IsNullOrEmpty(this.ddlShipTogether.SelectedValue))
                {
                    return base.GetParamsString(this.ddlShipTogether.SelectedValue, this.ddlShipTogetherOpr.SelectedValue);
                }
                return "";
            }
        }

        public string Status
        {
            get
            {
                if (!string.IsNullOrEmpty(this.MSCStatus.ReturnValue))
                {
                    return base.GetParamsString(this.MSCStatus.ReturnValue, this.ddlStatusOper.SelectedValue);
                }
                return "";
            }
        }

        public string Stop
        {
            get
            {
                return "";
            }
        }

        public string TransportMode
        {
            get
            {
                if (!string.IsNullOrEmpty(this.MSCTransportMode.ReturnValue))
                {
                    return base.GetParamsString(this.MSCTransportMode.ReturnValue, this.ddlTransportMode.SelectedValue);
                }
                return "";
            }
        }

        public string Type
        {
            get
            {
                if (!string.IsNullOrEmpty(this.MSCType.ReturnValue))
                {
                    return base.GetParamsString(this.MSCType.ReturnValue, this.ddlTypeOpr.SelectedValue);
                }
                return "";
            }
        }

        public string WaveID
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtWaveID.Text))
                {
                    return base.GetParamsString(this.txtWaveID.Text, this.ddlWaveID.SelectedValue);
                }
                return "";
            }
        }
    }
}

